$('form').on('submit', function (e) {
    e.preventDefault()
    let data = $(this).serialize()
    
    $.ajax({
        type:'POST',
        url: '/my/user/updatepwd',
        data: data,
        success: function (res) {
            if (res.status === 0) {
            layer.msg(res.message)
                $('form')[0].reset()
                localStorage.removeItem('token')
                
                window.parent.location.href='../../login.html'
           }
        }       
    })
})
//--------表单验证-----
let form = layui.form
form.verify({
    password: [/^\S{6,12}$/, '密码长度必须由6-10位数字字母组成'],
    diff: function (val) {
        if ($('input').eq(0).val() === val) {
            return '新旧密码不能一致'
        }
    },
    ooo: function (pass) {
        if (pass !== $('.pwd').val()) {
            return '两次密码不一致'
        }
    }
})